/* 
 * File:   EntityCreator.h
 * Author: RedEyedKiller
 *
 * Created on 26 Σεπτέμβριος 2010, 4:28 μμ
 */

#ifndef ENTITYCREATOR_H
#define	ENTITYCREATOR_H

#include <map>

//predefinitions
namespace FileParser
{
class EntityParser;
}

namespace EntitySystem
{
class EntityCreator
{
public:
    
    EntityCreator();
    
    virtual ~EntityCreator();
    
    /**
     * @brief Returns a new entity as described in its script.
     * @param key - The name of the entity (script) to be created.
     * @return The new entity.
     */
    Entity* CreateEntity(const std::string& key);
    
    /**
     * Creates A new entity as above but its used only in case of inheritance.
     * @param key
     * @param child
     * @return 
     */
    Entity* CreateEntity(const std::string& key,const std::string& child);
    
    /**
     * Returns true if key has already been asigned to a value.
     * @param key
     * @return 
     */
    bool CheckPrototype(const std::string& key);
    
    /**
     * Registers the given entity as a prototype to be created later via CreateEntity.
     * @param prototype
     * @param key
     * @return 
     */
    bool RegisterEntityPrototype(Entity* prototype,const std::string& key);
    
    /**
     * Deletes all prototypes cached. Most common use between diferent levels which
     * use different Entities.
     */
    void ResetCache();
private:
    std::map<std::string,Entity*> prototypes;
    FileParser::EntityParser* parser;
};

};

#endif	/* ENTITYCREATOR_H */

